package org.apache.http.entity.mime;

import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;

public class c implements Iterable {
    private final List a = new LinkedList();
    private final Map b = new HashMap();

    public i a(String str) {
        if (str == null) {
            return null;
        }
        List list = (List) this.b.get(str.toLowerCase(Locale.ENGLISH));
        return (list == null || list.isEmpty()) ? null : (i) list.get(0);
    }

    public void a(i iVar) {
        if (iVar != null) {
            String toLowerCase = iVar.a().toLowerCase(Locale.ENGLISH);
            List list = (List) this.b.get(toLowerCase);
            if (list == null) {
                list = new LinkedList();
                this.b.put(toLowerCase, list);
            }
            list.add(iVar);
            this.a.add(iVar);
        }
    }

    public Iterator iterator() {
        return Collections.unmodifiableList(this.a).iterator();
    }

    public String toString() {
        return this.a.toString();
    }
}
